//
//  CYRentTransfer.m
//  CreditAddressBook
//
//  Created by LE on 16/1/11.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "CYRentTransfer.h"
#import "MDSlider.h"

@interface CYRentTransfer ()

@property (weak, nonatomic) IBOutlet MDSlider *sliderView;
@property (weak, nonatomic) IBOutlet UILabel *showLabel;

@property(nonatomic, copy) CYSliderView sliderBlock;
@end

@implementation CYRentTransfer

- (void)setMaximumValue:(CGFloat)maximumValue {
    _maximumValue = maximumValue;
    
    CGFloat step = 5000;
    if (maximumValue < step) {
        self.sliderView.enabled = NO;
    } else {
        self.sliderView.enabled = YES;
        self.sliderView.step = step;
        self.sliderView.minimumValue = 0;
        int multiple = maximumValue/step;
        self.sliderView.maximumValue = multiple*step;
    }
}

- (void)awakeFromNib {
    self.sliderView.enabled = NO;
}

- (void)sliderViewChange:(CYSliderView)slider {
    self.sliderBlock = [slider copy];
}

- (IBAction)sliderView:(MDSlider *)sender {
    self.showLabel.text = CYStringFormat(@"金额：%.1f", sender.value);
    if (self.sliderBlock) {
        self.sliderBlock(sender);
    }
}

- (void)completion {
    self.sliderBlock = nil;
}

- (void)setFrame:(CGRect)frame {
    frame.size.height = 110;
    [super setFrame:frame];
}
@end
